package com.jk.utils;

import com.jk.pojo.PagedResponse;

import java.util.List;

public class PaginationUtil {
    public static <T> PagedResponse<T> getPaginationResponse(List<T> items, Integer pageNum, Integer pageSize, long total) {
        // yzf TODO 2025/3/9 分页:

        PagedResponse<T> response = new PagedResponse<>();
        response.setItems(items);
        response.setPage(pageNum);
        response.setSize(pageSize);
        response.setTotalElements(total);
        response.setTotalPages((int)Math.ceil((double)total / pageSize));
        return response;
    }
}
